HAL I2S types migration

This section provides information about the HAL I2S types migration.

HAL I2S callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_I2S_TX_COMPLETE_CB_ID,
  HAL_I2S_RX_COMPLETE_CB_ID,
  HAL_I2S_TX_RX_COMPLETE_CB_ID,
  HAL_I2S_TX_HALF_COMPLETE_CB_ID,
  HAL_I2S_RX_HALF_COMPLETE_CB_ID,
  HAL_I2S_TX_RX_HALF_COMPLETE_CB_ID,
  HAL_I2S_ERROR_CB_ID,
  HAL_I2S_MSPINIT_CB_ID,
  HAL_I2S_MSPDEINIT_CB_ID
} HAL_I2S_CallbackIDTypeDef;

Removed.

Note

The callback registration in HAL2 is now handled by dedicated functions for each I2S event. See HAL I2S callbacks register and unregister functions for more details.

HAL_I2S_MSPINIT_CB_ID and HAL_I2S_MSPDEINIT_CB_ID are removed because the functions HAL_I2S_MspInit() and HAL_I2S_MspDeInit() no longer exist in HAL2.

Related concepts:


HAL I2S state type definition

HAL1

HAL2

typedef enum
{
  HAL_I2S_STATE_RESET
  HAL_I2S_STATE_READY
  HAL_I2S_STATE_BUSY
  HAL_I2S_STATE_BUSY_TX
  HAL_I2S_STATE_BUSY_RX
  HAL_I2S_STATE_BUSY_TX_RX
  HAL_I2S_STATE_TIMEOUT
  HAL_I2S_STATE_ERROR
} HAL_I2S_StateTypeDef;
typedef enum
{
  HAL_I2S_STATE_RESET
  HAL_I2S_STATE_INIT
  HAL_I2S_STATE_IDLE
  HAL_I2S_STATE_TX_ACTIVE
  HAL_I2S_STATE_RX_ACTIVE
  HAL_I2S_STATE_TX_RX_ACTIVE
  HAL_I2S_STATE_PAUSED
  HAL_I2S_STATE_ABORT
} hal_i2s_state_t;

Related concept: Revised and optimized HAL state machine


HAL I2S handle type definition

HAL1

HAL2

I2S_HandleTypeDef
hal_i2s_handle_t

Related concepts:


HAL I2S initialization type definition

The hal_i2s_config_t structure is simplified to include only the essential parameters, with additional configurations handled by separate functions.

HAL1

HAL2

typedef struct
{
  uint32_t Mode;


  uint32_t Standard;


  uint32_t DataFormat;


  uint32_t AudioFreq;


  uint32_t CPOL;


  uint32_t FirstBit;


  uint32_t MCLKOutput;


  uint32_t WSInversion;


  uint32_t MasterKeepIOState;


  uint32_t Data24BitAlignment;


} I2S_InitTypeDef;
typedef struct
{
  hal_i2s_mode_t            mode;


  hal_i2s_standard_t        standard;


  hal_i2s_data_format_t     data_format;


  hal_i2s_audio_frequency_t audio_frequency;


  hal_i2s_clock_polarity_t  clock_polarity;


  hal_i2s_bit_order_t       bit_order;
} hal_i2s_config_t;

hal_status_t HAL_I2S_EnableMclkOutput(hal_i2s_handle_t *hi2s);
hal_status_t HAL_I2S_DisableMclkOutput(hal_i2s_handle_t *hi2s);

hal_status_t HAL_I2S_EnableWSInversion(hal_i2s_handle_t *hi2s);
hal_status_t HAL_I2S_DisableWSInversion(hal_i2s_handle_t *hi2s);

hal_status_t HAL_I2S_EnableMasterKeepIOState(hal_i2s_handle_t *hi2s);
hal_status_t HAL_I2S_DisableMasterKeepIOState(hal_i2s_handle_t *hi2s);

Note

The Data24BitAlignment member of the I2S_InitTypeDef structure in HAL1 has been merged into the hal_i2s_data_format_t enumeration in HAL2. For more details, refer to HAL I2S data format constants.

Related concept: Removal and conversion of init structure to configuration structure


HAL I2S callback type definition

HAL1

HAL2

pI2S_CallbackTypeDef

hal_i2s_cb_t

Related concept: Replaced TypeDef suffix with _t in type names